package beans;

import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "log_parcel")
public class LogParcel {
	private int id;// 日志id
	private Package parcel;// 包裹（外键）
	private Timestamp time;// 操作时间
	private Agent agent;// 管理员（外键）
	private User user;// 用户（外键）
	private Admin admin;// 管理员（外键）
	private Courier courier;// 快递员（外键）
	private String operate;// 操作内容
	private String comment;// 备注

	/**
	 * 构造包裹日志（管理员）
	 * 
	 * @param parcel
	 * @param time
	 * @param agent
	 * @param operate
	 * @param comment
	 */
	public LogParcel(Package parcel, Timestamp time, Agent agent,
			String operate, String comment) {
		this.parcel = parcel;
		this.time = time;
		this.agent = agent;
		this.operate = operate;
		this.comment = comment;
	}

	/**
	 * 构造包裹日志（用户）
	 * 
	 * @param id
	 * @param parcel
	 * @param time
	 * @param user
	 * @param operate
	 * @param comment
	 */
	public LogParcel(Package parcel, Timestamp time, User user, String operate,
			String comment) {
		this.parcel = parcel;
		this.time = time;
		this.user = user;
		this.operate = operate;
		this.comment = comment;
	}

	/**
	 * 构造包裹日志（快递员）
	 * 
	 * @param id
	 * @param parcel
	 * @param time
	 * @param courier
	 * @param operate
	 * @param comment
	 */
	public LogParcel(Package parcel, Timestamp time, Courier courier,
			String operate, String comment) {
		this.parcel = parcel;
		this.time = time;
		this.courier = courier;
		this.operate = operate;
		this.comment = comment;
	}

	public LogParcel() {
		super();
	}

	@GenericGenerator(name = "generator", strategy = "native")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "log_parcel_id", unique = true, nullable = false)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name = "log_parcel_parcelID")
	public Package getParcel() {
		return parcel;
	}

	public void setParcel(Package parcel) {
		this.parcel = parcel;
	}

	@Column(name = "log_parcel_time")
	public Timestamp getTime() {
		return time;
	}

	public void setTime(Timestamp time) {
		this.time = time;
	}

	@ManyToOne
	@JoinColumn(name = "log_parcel_agentID")
	public Agent getAgent() {
		return agent;
	}

	public void setAgent(Agent agent) {
		this.agent = agent;
	}

	@ManyToOne
	@JoinColumn(name = "log_parcel_userID")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne
	@JoinColumn(name = "log_parcel_courierID")
	public Courier getCourier() {
		return courier;
	}

	public void setCourier(Courier courier) {
		this.courier = courier;
	}

	@Column(name = "log_parcel_operate")
	public String getOperate() {
		return operate;
	}

	public void setOperate(String operate) {
		this.operate = operate;
	}

	@Column(name = "log_parcel_comment")
	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}
	@ManyToOne
	@JoinColumn(name = "log_parcel_adminID")
	public Admin getAdmin() {
		return admin;
	}

	public void setAdmin(Admin admin) {
		this.admin = admin;
	}
}
